﻿using QunProject.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EnumHelper = QunProject.Model.EnumHelper;

namespace QunProject.Manage.Controllers
{
    public class ResourceController : BaseController
    {
        // 首页
        public ActionResult Index()
        {
            return View();
        }
        // 获取数据
        public JsonResult AjaxData(int articleId, int page = 1, int limit = 20)
        {
            var list = EF.resource.Where(x => x.ArticleID == articleId);

            var data = list.OrderByDescending(x => x.CreateTime).ToList().Skip((page - 1) * limit).Take(limit).Select(x => new
            {
                x.ID,
                CreateTime = x.CreateTime.Value.ToString("yyyy-MM-dd hh:mm:ss"),
                x.Remark,
                x.ArticleID,
                x.Source,
                x.Name,
                x.Url,
                x.Password
            });

            return Json(Result.SuccessReturnData(list.Count(), data));
        }
    }
}